<?

define("PRIMARY_KEY","nik");
$FileName       = "ais_transaction_dnbook_rpc.php";
$HTMLFormName   = "DNSummaryForm";

if (GetParam("blno","")) {
	$SQL = "
			(SELECT bl.BLNO,BLOTHERNAME, BLOTHER, BLDOC,BCCONTYPESIZE as BDCCRTYPE,count(BCCONTYPESIZE) as BDCQTY,sum(BCRATE) as BDCRATE 
			FROM $DBName2.bookingcontainer
			INNER JOIN $DBName2.bl ON bl.BONO=bookingcontainer.BONO
			WHERE bookingcontainer.BLNO = '".GetParam("blno","")."'
			GROUP BY BCCONTYPESIZE)

			UNION

			(SELECT bl.BLNO,BLOTHERNAME, BLOTHER, BLDOC,BDBGOODSDESC as BDCCRTYPE,count(BDBGOODSDESC) as BDCQTY,sum(BBRATE) as BDCRATE
			FROM $DBName2.bookingbreakbulk
			INNER JOIN $DBName2.bl ON bl.BONO=bookingbreakbulk.BONO
			WHERE bookingbreakbulk.BLNO = '".GetParam("blno","")."'
			GROUP BY BDBGOODSDESC)

			";
	$data = $DBConnection->dbc->get_results($SQL);
	if ($data) {
		foreach ($data as $DataBL ) {
			$DocumentFee = $DataBL->BLDOC;
			$OtherName   = $DataBL->BLOTHERNAME;
			$OtherFee    = $DataBL->BLOTHER;
?>
			eval("opener.document.<?=$HTMLFormName?>.uraian"+opener.idx+".value = \"<?=$DataBL->BDCCRTYPE?> X <?=$DataBL->BDCQTY?>\"");
			eval("opener.document.<?=$HTMLFormName?>.noref"+opener.idx+".value = \"<?=$DataBL->BLNO?>\"");
			eval("opener.document.<?=$HTMLFormName?>.jumlah"+opener.idx+".value = \"<?=FormatNumber($DataBL->BDCRATE)?>\"");
			eval("opener.document.<?=$HTMLFormName?>.dk"+opener.idx+".value = \"K\"");
			opener.idx++;
			eval("opener.document.getElementById('"+opener.idx+"').style.display = \"\"");
<?			
		}
		if (strlen($OtherName)) {
			//Other Fee
?>
			eval("opener.document.<?=$HTMLFormName?>.uraian"+opener.idx+".value = \"<?=$OtherName?>\"");
			eval("opener.document.<?=$HTMLFormName?>.noref"+opener.idx+".value = \"<?=$DataBL->BLNO?>\"");
			eval("opener.document.<?=$HTMLFormName?>.jumlah"+opener.idx+".value = \"<?=FormatNumber($OtherFee)?>\"");
			eval("opener.document.<?=$HTMLFormName?>.dk"+opener.idx+".value = \"K\"");
			opener.idx++;
			eval("opener.document.getElementById('"+opener.idx+"').style.display = \"\"");
<?
	  }
	  if ($DocumentFee>0) {
?>
			eval("opener.document.<?=$HTMLFormName?>.uraian"+opener.idx+".value = \"DOCUMENT FEE\"");
			eval("opener.document.<?=$HTMLFormName?>.noref"+opener.idx+".value = \"<?=$DataBL->BLNO?>\"");
			eval("opener.document.<?=$HTMLFormName?>.jumlah"+opener.idx+".value = \"<?=FormatNumber($DocumentFee)?>\"");
			eval("opener.document.<?=$HTMLFormName?>.dk"+opener.idx+".value = \"K\"");
			opener.idx++;
			eval("opener.document.getElementById('"+opener.idx+"').style.display = \"\"");
<?
		}
	}


}
?>
opener.GetTotal ();